<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function LongestSubstring(s = '') {
        if (s.length <= 1) return s.length
        let max = 0 //最大长度
        for (let i = 0; i < s.length; i++) {
          let subStr = s[i]
          for (let j = i + 1; j <= s.length; j++) {
            if (j === s.length) {
              max = Math.max(max, subStr.length)
            } else if (subStr.includes(s[j])) {
              max = Math.max(max, subStr.length)
              break
            } else {
              subStr += s[j]
            }
          }
        }
        return max
      }
      console.log(LongestSubstring('abca'))
    </script>
  </body>
</html>
